﻿@{
    Layout = null;
    ViewData["Title"] = "编辑管理员";
    var role = ViewBag.role as List<BuyWithoutLoseMoney.Core.Models.Role>;
    //var loginUser = ViewBag.role as List<BuyWithoutLoseMoney.Core.Models.Role>;

}
@model BuyWithoutLoseMoney.Core.Models.LoginUser;
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Edit</title>
    <link href="/layui/css/layui.mobile.css" rel="stylesheet" />
    <link href="/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
    <div>
        <div class="layui-card">
            <div class="layui-card-header">添加管理员角色</div>
            <div class="layui-card-body">
                <form class="layui-form">
                    <input type="hidden" name="LoginUserId" value="@Model.Id" />
                    <div class="layui-form-item">
                        <label class="layui-form-label">产品分类</label>
                        <div class="layui-input-block">
                            <select name="RoleId" lay-verify="required">
                                @foreach (var item in role)
                                {
                                    <option value="@item.Id">@item.Name</option>
                                }
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="addForm">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
    <script src="/js/vue.js"></script>
    <script src="/layui/layui.js"></script>
    <script>
        layui.use(["form", 'layer'], function() {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;

            form.on('submit(addForm)', function(data) {
                $.post("/admin/management/edit", data.field, function(res) {
                    if (res.isSuccess) {
                        layer.msg(res.msg, function() {
                            parent.window.location.href = "/admin/management/index";
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                });
                return false;
            });
        })
    </script>
</body>
</html>